#ifndef THERMOMETERWIDGET_H
#define THERMOMETERWIDGET_H

#include <QWidget>
#include <QPropertyAnimation>

class ThermometerWidgetPrivate;
class ThermometerWidget : public QWidget
{
    Q_OBJECT
    Q_PROPERTY(double value READ getValue  WRITE setValue)
    Q_PROPERTY(double minValue READ getMinValue  WRITE setMinValue)
    Q_PROPERTY(double maxValue READ getMaxValue  WRITE setMaxValue)
    Q_DECLARE_PRIVATE(ThermometerWidget)

public:
    explicit ThermometerWidget(QWidget *parent = nullptr);

    double getValue();
    double getMinValue();
    double getMaxValue();

public Q_SLOTS:
    //动画设置温度值
    void setValueWithAnimation(double value);

    //设置温度值
    void setValue(double value);
    void setValue(int value);

    //设置最大最小值
    void setMinValue(double minValue);
    void setMaxValue(double maxValue);

Q_SIGNALS:
    void valueChange(double value);

protected:
    void resizeEvent(QResizeEvent *) override;
    void paintEvent(QPaintEvent *) override;

    //绘制水银柱背景
    void drawBarBg(QPainter *painter);

    //绘制刻度尺
    void drawRuler(QPainter *painter);

    //绘制当前水银柱
    void drawBar(QPainter *painter);

    //绘制当前温度值
    void drawValue(QPainter *painter);

private:
    ThermometerWidgetPrivate *d_ptr;
};

#endif // THERMOMETERWIDGET_H

